#include <iostream>
#include <stack>

using namespace std;

const int N = 110;

bool st[N]; // st[i] 标记是否已经匹配

int main()
{
	string s; cin >> s;
	stack<int> stk; // 里面存的是左括号的下标

	for(int i = 0; i < s.size(); i++)
	{
		char ch = s[i];
		//如果是左括号，就将其下标入栈
		if(ch == '[' || ch == '(') stk.push(i);
		else 
		{
			//右括号
			if(stk.empty()) continue;

			//和栈顶元素看一下是否匹配
			int t = stk.top();
			char left = s[t];
			if((left == '[' && ch == ']')
				|| (left == '(' && ch == ')'))
			{
				//匹配的话标记为true，并出栈顶元素
				st[t] = st[i] = true;
				stk.pop();
			}
		}
	}

	//还原字符串
	string ret = "";
	for(int i = 0; i < s.size(); i++)
	{
		char ch = s[i];
		if(st[i]) ret += ch;
		else 
		{
			if(ch == '(')
			{
				ret += ch;
				ret += ')';
			}
			else if(ch == ')')
			{
				ret += '(';
				ret += ch;
			}
			else if(ch == '[')
			{
				ret += ch;
				ret += ']';
			}
			else  
			{
				ret += '[';
				ret += ch;
			}
		}
	}
	cout << ret << endl;


	return 0;
}

